<% layout('/layouts/default.html', {title: '充值列表', libs: ['dataGrid']}){ %>
<div class="main-content">


	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('流水明细')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('admin:adminData:view')){ %>
				<a href="#" class="btn btn-default" id="btnDelUser" title="批量审核"><i class="fa fa-filter"></i> 批量审核</a>
				<div class="btn-group">
					<a href="javascript:" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
						<i class="fa fa-navicon"></i> <span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="javascript:" id="btnExport"><i class="glyphicon glyphicon-export"></i> 导出</a></li>
					</ul>
				</div>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${ztFinancial}" action="${ctx}/ztFinancial/listselfData" method="post" class="form-inline hide"

					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div class="form-group">
				<label class="control-label">${text('开始时间')}：</label>
				<div class="control-inline">
					<#form:input type="date" path="CreateDate_gte" maxlength="200" class="form-control width-160"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('结束时间')}：</label>
				<div class="control-inline">
					<#form:input type="date" path="CreateDate_lte" maxlength="200" class="form-control width-160"/>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label">${text('归属公司')}：</label>

				<div class="control-inline width-270">
					<select name='companyId' style="width:auto;min-width: 90px;padding:6px;border-color:#d2d6de"></select>
				</div>

			</div>
			<div class="form-group">
					<label class="control-label">${text('类型')}：</label>
				   <div class="control-inline width-270">
					<select name='audit' style="width:auto;min-width: 90px;padding:6px;border-color:#d2d6de">
						<option value=''>全部</option>
						<option value='1'>未审核</option>
						<option value='2'>已审核</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('类型')}：</label>

				<div class="control-inline width-270">
					<select name='type' style="width:auto;min-width: 90px;padding:6px;border-color:#d2d6de">
						<option value=''>全部</option>
						<option value='1'>未充值</option>
						<option value='2'>已充值</option>
						<option value='3'>支出</option>
						<option value='5'>退款</option>
					</select>
				</div>

			</div>
				<div class="form-group">

					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>

					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>

				</div>


		</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>

</div>
<% } %>
<script>
	// 初始化第一类型
	initAddress();

	// 更改省份后的操作
	$("select[name='companyId']").change(function() {
		var provCode = $("select[name='companyId']").val();
	});


	function initAddress() {

		// ajax请求所有省份
		$.get("${ctx}/ztCompany/listData", {
		}, function(data) {
			$("select[name='companyId']").empty();

			$("select[name='companyId']").append("<option value=''>其他用户</option>");
			$.each(data.list, function(i, d) {
				$("select[name='companyId']").append("<option value='"+d.company+"'>"+ d.companyname +"</option>");
			});

		}, 'json');

	}
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	columnModel: [
		{header:'${text('流水号')}', name:'id',index:'id',  width:150, align:"center"},
		{header:'${text('用户名称')}', name:'username',index:'username',  width:150, align:"center"},
		{header:'${text('公司名称')}', name:'companyName',index:'companyName',  width:150, align:"center"},
		{header:'${text('显示状态')}', name:'type',index:'type',  width:105, align:"center",formatter: function(val, obj, row, act) {
				if(row.type==1){
					return "未充值";
				}else if(row.type==2){
					return "已充值"
				}else if(row.type==3){
					return "支出"
				}else if(row.type==4){
					return "提现"
				}else if(row.type==5){
					return "已退款"
				}
			}},
		{header:'${text('审核状态')}', name:'audit',index:'audit', width:105, align:"center",formatter: function(val, obj, row, act) {
			if(row.audit==1){
				return "未审核";
			}else{
				return "已审核"
			}
		}},
		{header:'${text('明细')}', name:'content', index:'content', width:220, align:"center"},
		{header:'${text('金额')}', name:'price', width:105, align:"center"},
		{header:'${text('时间')}', name:'createDate', index:'createDate', width:150, align:"center"},
		{header:'${text('手机号')}', name:'phone', index:'phone', width:150, align:"center"},
		{header:'${text('操作人')}', name:'operation', index:'operation', width:75, align:"center"}
		
	],
	showCheckbox: true,
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
$('#btnExport').click(function(){
	js.ajaxSubmitForm($('#searchForm'), {
		url:'${ctx}/ztFinancial/exportData',
		downloadFile:true
	});
});

$('#btnDelUser').click(function(){
	var ztFinancial = $('#dataGrid').dataGrid('getSelectRows');
	if (ztFinancial != null && ztFinancial.length > 0){
		js.confirm('确认要批量审核充值信息吗？', function(){
			js.ajaxSubmit('${ctx}/ztFinancial/audit', {
				str : ztFinancial.join(',')
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定审核信息！');
	}
	return false;
});


</script>
